import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from "path"; 

export default defineConfig({
  plugins:[vue()],
  //解决跨域
  server: {
    proxy: {
      '/biliProt': {
        target: 'https://passport.bilibili.com/', // 实际请求地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/biliProt/, ""),
      },
      '/api': {
        target: 'http://127.0.0.1:3000/', // 实际请求地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
      '/bili': {
        target: 'https://api.bilibili.com/', // 实际请求地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/bili/, ""),
      },
      '/video': {
        target: 'https://cn-hbsjz-cm-02-03.bilivideo.com/', // 实际请求地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/video/, ""),
      },
      '/vcbili':{
        target:'http://u002F/u002Fapi.bilibili.com/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/vcbili/, ""),
      },
      '/liveCard':{
        target:'https://api.live.bilibili.com/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/liveCard/, ""),
      },
      '/mangaCard':{
        target:'https://manga.bilibili.com/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/mangaCard/, ""),
      },
      '/game':{
        target:'https://le3-api.game.bilibili.com/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/game/, ""),
      },
      '/imgColor':{
        target:'https://i0.hdslb.com/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/imgColor/, ""),
      },
      '/search':{
        target:'https://search.bilibili.com/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/search/, ""),
      },
      '/csearch':{
        target:'https://s.search.bilibili.com/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/csearch/, ""),
      },
      '/bi':{
        target:'https://www.bilibili.com/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/bi/, ""),
      }
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: "@import 'src/assets/css/Var.scss';"
      }
    }
  },
  resolve: {
    // 配置路径别名
    alias: {
      "@": resolve(__dirname, "./src")
    },
  },
  build: {
    rollupOptions: {
      input: {
        main: resolve(__dirname, 'index.html'),
        video: resolve(__dirname, 'indexVideo.html'),
        comic: resolve(__dirname, 'indexComic.html'),
        tv: resolve(__dirname, 'indexTv.html'),
        search: resolve(__dirname, 'indexSearch.html'),
        up: resolve(__dirname, 'indexUp.html'),
      },
    },
  },
})

